Learn R Programming

ks (version 1.3.5)

kda, pda: Kernel and parametric discriminant analysis

Description

Kernel and parametric discriminant analysis.

Usage

kda(x, x.group, Hs, y, prior.prob=NULL)
pda(x, x.group, y, prior.prob=NULL, type="quad")

Arguments

x
matrix of training data values
x.group
vector of group labels for training data
y
matrix of test data
Hs
(stacked) matrix of bandwidth matrices
prior.prob
vector of prior probabilities
type
"line" = linear discriminant, "quad" = quadratic discriminant

Value

  • A vector of group labels estimated via a discriminant (or classification) rule. If the test data y are given then these are classified. Otherwise the training data x are classified.

Details

If you have prior probabilities then set prior.prob to these. Otherwise prior.prob=NULL is the default i.e. use the sample proportions as estimates of the prior probabilities.

The linear and quadratic discriminant analysers are based on lda and qda from the MASS library.

References

Silverman, B. W. (1986) Data Analysis for Statistics and Data Analysis. Chapman & Hall. London. Simonoff, J. S. (1996) Smoothing Methods in Statistics. Springer-Verlag. New York

Venables, W.N. & Ripley, B.D. (1997) Modern Applied Statistics with S-PLUS. Springer-Verlag. New York.

See Also

kda.kde, pda.pde, compare, compare.kda.cv, compare.pda.cv

Examples

Run this code
### bivariate example - restricted iris dataset  
library(MASS)
data(iris)
ir <- iris[,1:2]
ir.gr <- iris[,5]

H <- Hkda(ir, ir.gr, bw="plugin", pre="scale")
kda.gr <- kda(ir, ir.gr, H, ir)
lda.gr <- pda(ir, ir.gr, ir, type="line")
qda.gr <- pda(ir, ir.gr, ir, type="quad")

### multivariate example - full iris dataset
ir <- iris[,1:4]
ir.gr <- iris[,5]

H <- Hkda(ir, ir.gr, bw="plugin", pre="scale")
kda.gr <- kda(ir, ir.gr, H, ir)
lda.gr <- pda(ir, ir.gr, ir, type="line")
qda.gr <- pda(ir, ir.gr, ir, type="quad")

Run the code above in your browser using DataLab